package LC;

public class LC97 {
    public int maxSubArray (int[] A) {
        // write code here
        if(A==null||A.length==0) return 0;
        int ans = 0,max = Integer.MIN_VALUE;
        for (int i = 0; i < A.length; i++) {
            ans += A[i];
            max =Math.max(ans,max);
            ans = Math.max(ans, 0);
        }
        return max;
    }
}